package com.sita.linboard.wallet;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.sita.linboard.MainMessage.DriverDayMsgRequest;
import com.sita.linboard.R;
import com.sita.linboard.base.BaseActivity;
import com.sita.linboard.base.BaseApplication;
import com.sita.linboard.http.RestClient;
import com.sita.linboard.utils.SpUtils;

import retrofit.Callback;
import retrofit.RetrofitError;
import retrofit.client.Response;

/**
 * Created by Jason on 2016/9/1.
 */
public class MyWalletActivity extends BaseActivity implements View.OnClickListener{
    private TextView head_title,balance;
    private LinearLayout back;
    private LinearLayout record_money;

    private void getDriverWalletFromSer(){
        BalanceRequest request = new BalanceRequest();
    request.driver_id = SpUtils.getString("AccoundID",null, BaseApplication.getContext());
    RestClient.getRestService().MyWallet(request, new Callback<WalletBackBean>() {
        @Override
        public void success(WalletBackBean walletBackBean, Response response) {
                balance.setText(String.valueOf(walletBackBean.getData()));


        }

        @Override
        public void failure(RetrofitError error) {
        }
    });
}
    @Override
    protected void initData() {
        head_title.setText("钱包");
        getDriverWalletFromSer();
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        head_title = bindView(R.id.head_title);
        back = bindView(R.id.img_back);
        back.setVisibility(View.VISIBLE);
        back.setOnClickListener(this);
        balance = bindView(R.id.all_money);
        record_money = bindView(R.id.record);
        record_money.setOnClickListener(this);
    }

    @Override
    protected int getId() {
        return R.layout.activity_wallet;
    }
    public static void WalletIntent(Context context){
        Intent intent = new Intent(context,MyWalletActivity.class);
        context.startActivity(intent);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.img_back:
            finish();
                break;
            case R.id.record:
                //TODO 提现记录
           WithdrawalActivity.WithDrawalIntent(this);
                break;

        }
    }
}
